package com.atlzk.group.order.controller;

import java.util.Arrays;
import java.util.Map;

//import org.apache.shiro.authz.annotation.RequiresPermissions;
import com.atlzk.group.order.entity.OrderEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.atlzk.group.order.entity.KanEntity;
import com.atlzk.group.order.service.KanService;
import com.atlzk.common.utils.PageUtils;
import com.atlzk.common.utils.R;


/**
 * @author liuzekun
 * @email 2803587841@gmail.com
 * @date 2021-06-23 22:52:33
 */
@RestController
@RequestMapping("order/kan")
public class KanController {
    @Autowired
    private KanService kanService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("order:kan:list")
    public R list(@RequestParam Map <String, Object> params) {
        PageUtils page = kanService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{omsKanId}")
    //@RequiresPermissions("order:kan:info")
    public R info(@PathVariable("omsKanId") Long omsKanId) {
        KanEntity kan = kanService.getById(omsKanId);

        return R.ok().put("kan", kan);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("order:kan:save")
    public R save(@RequestBody KanEntity kan) {
        kanService.save(kan);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("order:kan:update")
    public R update(@RequestBody KanEntity kan) {
        kanService.updateById(kan);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("order:kan:delete")
    public R delete(@RequestBody Long[] omsKanIds) {
        kanService.removeByIds(Arrays.asList(omsKanIds));

        return R.ok();
    }

    @RequestMapping("/kan")
    public R kan(@RequestBody OrderEntity orderEntity) {
        kanService.kan(orderEntity);
        return R.ok();
    }
}
